﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Newtonsoft.Json;

public partial class NewStockAll : Basic
{
    public string strList = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        strList = sbList().ToString();
    }

    protected StringBuilder sbList()
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            string url = jsonUrl + "stock/NewStockList.ashx";
            string str = Pub.LoadData(url);
            List<NewStock> list = JsonConvert.DeserializeObject<List<NewStock>>(str);
            if (list != null)
                list = list.OrderByDescending(o => o.fxrq).ToList();
            int _totalCount = 0;
            int _pagesize = 20;
            int _totalPage = 0;
            _totalCount = list.Count;
            if (_totalCount > 0)
            {
                if ((_totalCount % _pagesize) == 0)
                    _totalPage = _totalCount / _pagesize;
                else
                    _totalPage = (int)(_totalCount / _pagesize) + 1;
            }
            int page = OTO.ToInt(Request["page"], 1);
            if (page == 0)
                page = 1;
            if (page > _totalPage)
                page = _totalPage;
            int _index = (page - 1) * _pagesize;
            int _end = page * _pagesize;
            if (page == _totalPage && (_totalCount % _pagesize) != 0)
                _end = (page - 1) * _pagesize + _totalCount % _pagesize;

            sb.AppendLine("<div class=\"tableLarge\">");
            sb.AppendLine("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">");
            sb.AppendLine("  <tr class=\"tableLargeHead\">");
            sb.AppendLine("    <td>股票代码</td>");
            sb.AppendLine("    <td >股票简称</td>");
            sb.AppendLine("    <td >申购代码</td>");
            sb.AppendLine("    <td class=\"lineHeight\">发行总数<br />(万股)</td>");
            sb.AppendLine("    <td class=\"lineHeight\">网上发行<br />");
            sb.AppendLine("      (万股)</td>");
            sb.AppendLine("    <td class=\"lineHeight\">申购上限<br />");
            sb.AppendLine("      (股)</td>");
            sb.AppendLine("    <td >申购日期</td>");
            sb.AppendLine("    <td class=\"lineHeight\">发行价<br />");
            sb.AppendLine("      (元)</td>");
            sb.AppendLine("    <td class=\"lineHeight\">发行市<br />");
            sb.AppendLine("      盈率</td>");
            sb.AppendLine("    <td class=\"lineHeight\">中签率<br />");
            sb.AppendLine("      (%)</td>");
            sb.AppendLine("    <td class=\"lineHeight\">每中一签约<br />");
            sb.AppendLine("      (元)</td>");
            sb.AppendLine("    <td >上市日</td>");
            sb.AppendLine("    <td >当前价<br />(元)</td>");
            sb.AppendLine("    <td class=\"lineHeight\">上市后<br />");
            sb.AppendLine("      涨跌幅");
            sb.AppendLine("      (%)</td>");
            //sb.AppendLine("    <td >详细</td>");
            sb.AppendLine("  </tr>");
            for (int i = _index; i < _end; i++)
            {
                sb.AppendLine("<tr>");
                sb.AppendFormat("  <td><a href=\"{1}gg{0}.shtml\" class=\"b\">{0}</a></td>", OTO.ToStr(list[i].gpdm, "&nbsp;"), quoteUrl);
                sb.AppendFormat("  <td><a href=\"{2}gg{1}.shtml\" class=\"b\">{0}</a></td>", OTO.ToStr(list[i].gpjc, "&nbsp;"), OTO.ToStr(list[i].gpdm, "&nbsp;"), quoteUrl);
                sb.AppendLine("  <td>" + OTO.ToStr(list[i].sgdm, "&nbsp;") + "</td>");
                sb.AppendLine("  <td>" + OTO.CoUt(list[i].zfxgs, 10000, "", 0) + "</td>");
                sb.AppendLine("  <td>" + OTO.CoUt(list[i].fxgs, 10000, "", 0) + "</td>");
                sb.AppendLine("  <td>" + OTO.ToLongLine(list[i].sgsl, "-") + "</td>");
                sb.AppendLine("  <td>" + OTO.ToDateLine(list[i].fxrq, 1) + "</td>");
                sb.AppendLine("  <td class=\"red\">" + OTO.ToDecLine(list[i].fxjg, 2, "-") + "</td>");
                sb.AppendLine("  <td>" + OTO.ToDecLine(list[i].fxsyl, 2, "-") + "</td>");
                sb.AppendLine("  <td>" + OTO.ToDecLine(list[i].fxzql, 2, "-") + "</td>");
                sb.AppendLine("  <td>" + OTO.ToDecLine(list[i].Fxqy, 2, "-") + "</td>");
                sb.AppendLine("  <td>" + OTO.ToDateLine(list[i].ssrq, 1) + "</td>");
                sb.AppendLine("<td align=\"center\" ><span zxj=\"zxj\" code=\"" + list[i].gpdm + "\" class=\"red\">-</span></td>");
                sb.AppendLine("<td align=\"center\"><span zdf=\"zdf\" zdfv=\"" + list[i].fxjg + "\">-</span></td>");
                //sb.AppendLine("  <td class=\"blue\">详细</td>");
                sb.AppendLine("</tr>");
            }
            sb.AppendLine("    </table>");
            sb.AppendLine("</div>");

            sb.AppendLine("<div class=\"news_next\">" + PageHelper.fy(_totalCount, _pagesize, page, Request.Url.AbsoluteUri) + "</div>");


        }
        catch { }
        return sb;
    }


}